
/**
 * This class defines an RGB (red/green/blue) color.
 * 
 * @author Dennis Mitchell 
 * @version 1.001 09/09/2010
 */
public class RgbColor
{

    //data members
    private Integer red;
    private Integer green;
    private Integer blue;

    //valid ranges for css properties
    private static final int COLOR_MIN=0;
    private static final int COLOR_MAX=255;
    
    /**
     * Constructor for objects of class RgbColor
     * @param red amount of red in color (0-255)
     * @param green amount of green in color (0-255)
     * @param blue amount of blue in color (0-255)
     */
    public RgbColor(Integer red, Integer green, Integer blue) throws Exception
    {
        if(red < COLOR_MIN || red > COLOR_MAX || 
            green < COLOR_MIN || green > COLOR_MAX || 
            blue < COLOR_MIN || blue > COLOR_MAX)
            throw new Exception("color param out of range, must be 0-255");
            
        this.red = red;
        this.green = green;
        this.blue = blue;
    }

    /**
     * Generates the html for the color (e.g., rgb(255,255,0))
     */
    public String getHtml()
    {
        // put your code here
        return "rgb(" + red.toString() + "," + green.toString() + "," + blue.toString() + ")";
    }
}
